package com.eax.ModelLayer;
import java.util.ArrayList;

public class DVDCollectionModel {
	private ArrayList<DVDModel> dvdCollection;

	public DVDCollectionModel(){
		dvdCollection = new ArrayList<DVDModel>();
	}

	public DVDModel getDVDById(int id){
		DVDModel dvd = null;

		for(DVDModel m : dvdCollection){
			if(m.getId() == id){
				dvd = m;
			}
		}

		return dvd;
	}

	public void addDVD(int id, String title, String artist, String releaseDate){
		DVDModel newDVD = new DVDModel(id, title, artist, releaseDate);
		dvdCollection.add(newDVD);
	}

	public void removeDVD(DVDModel dvd){
		dvdCollection.remove(dvd);
	}

	public int getSize(){
		return dvdCollection.size();
	}

	public ArrayList<DVDModel> getAllDvds(){
		return dvdCollection;
	}

	public void printAllDVDS(){
		for(DVDModel d : dvdCollection){
			d.printInfo();
			System.out.println();
		}
	}

	public int getHighestId(){
		int i = 0;

		for(DVDModel d : dvdCollection){
			if(d.getId() > i){
				i = d.getId();
			}
		}

		return i;
	}
}